import React, { useState } from 'react'

useUpdateInput = (initialValue) => {
	const [value, setValue] = useState(initialValue)

	return {
		value,
		onChange: (event) => setValue(event.target.value),
	}
}

const App = () => {
	const usernameInput = useUpdateInput('')
	const usewordInput = useUpdateInput('')
	const submitForm = (event) => {
		event.perventDefault()
		console.log(usernameInput.value)
		console.log(usewordInput.value)
	}
	return (
		<form onSubmit={submitForm}>
			<input type="text" name="username" {...usernameInput} />
			<input type="password" name="password" {...usewordInput} />
			<input type="submit" />
		</form>
	)
}

export default App
